<?php
	/**
	 * 
	 */
	class GroupAction extends CommonAction {
		function _filter(&$map){
			if (isset($_GET['pid'])){
				$map['pid'] = $_GET['pid'];
			}else{
				$map['pid'] = 0;
			}
	    }
	    
	    public function _before_add(){
	    	$model = M('Group');
			$list = $model->where("pid=0")->select();
			$this->assign("option",$list);
	    }
		
		public function _before_edit(){
			$model = M('Group');
			$list = $model->where("pid=0")->select();
			$currid = $model->where("id='".$_GET['id']."'")->getField('pid');
			$this->assign("option",$list);
			$this->assign("currid",$currid);
		}
		
		/**
	     +----------------------------------------------------------
	     * 默认排序操作
	     +----------------------------------------------------------
	     * @access public
	     +----------------------------------------------------------
	     * @return void
	     +----------------------------------------------------------
	     * @throws FcsException
	     +----------------------------------------------------------
	     */
	    public function sort(){
			$node = M('Group');
	        if(!empty($_GET['sortId'])) {
	            $map = array();
	            $map['status'] = 1;
	            $map['id']   = array('in',$_GET['sortId']);
	            $sortList   =   $node->where($map)->order('sort asc')->select();
	        }else{
	            $sortList   =   $node->where('status=1')->order('sort asc')->select();
	        }
	        $this->assign("sortList",$sortList);
	        $this->display();
	        return ;
	    }
	}
	
?>